<?php
header("content-type:text/html;charset=utf-8");
include 'config.php';
include 'Page.class.php';

$sqlCount="select count(*) from user";
$rstCount=$mysqli->query($sqlCount);
$rowCount=$rstCount->fetch_row();

// 总数
$total=$rowCount[0];

// 分页类
$page=new Page($total,2);

// 输出每页的数据
$sqlUser="select * from user order by id {$page->limit}";
$rstUser=$mysqli->query($sqlUser);

?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>分页</title>
</head>
<body>
	<center>
		<h3>分页</h3>
		<table border="1" cellspacing="0" width="600px">
			<tr>
				<th>ID</th>
				<th>用户名</th>
				<th>密码</th>
				<th>注册时间</th>
			</tr>
			<?php
				while ($rowUser=$rstUser->fetch_assoc()) {
					echo "<tr>";
					echo "<td>{$rowUser['id']}</td>";
					echo "<td>{$rowUser['username']}</td>";
					echo "<td>{$rowUser['password']}</td>";
					echo "<td>".date('Y-m-d H:i:s',$rowUser['time'])."</td>";
					echo "</tr>";
				}
			?>
		</table>
		<?php
			$page->show();
		?>
	</center>
</body>
</html>